package br.com.rafael.gestorinvestimentos.DAO;

import java.util.List;

import org.hibernate.Session;
import br.com.rafael.gestorinvestimentos.model.Composicao;

public class ComposicaoDAO {

	private Session session;
	
	public ComposicaoDAO(Session session){
		this.session = session;
	}	
	
	public void insert (Composicao composicao){
		this.session.save(composicao);
	}
	
	public void update (Composicao composicao){
		this.session.merge(composicao);
	}
	
	public void delete (Composicao composicao){
		this.session.delete(composicao);
	}
	
	public Composicao getComposicao (int id){
		return (Composicao) session.load(Composicao.class, id);
	
	}
	
	public List getList (){
		return this.session.createCriteria(Composicao.class).list();
	}
}
